package com.gitee.feizns.explore.data_structure.tree.bs.mid;

/**
 * @author feizns
 * @since 2020/3/17
 */
public class InsertIntoMaxTree {

    public static void main(String[] args) {

    }

    public static TreeNode insertIntoMaxTree(TreeNode root, int val) {
        if ( root != null ) {
            if ( root.val < val ) {
                TreeNode ret = new TreeNode(val);
                ret.left = root;
                return ret;
            } else
                root.right = insertIntoMaxTree(root.right, val);
            return root;
        }
        return new TreeNode(val);
    }

}
